fix logic of ballooning out to handle the dom0_min_mem parameter correctly
authorvh249@arcadians.cl.cam.ac.uk <vh249@arcadians.cl.cam.ac.uk>
Sun, 21 Aug 2005 16:49:54 +0000 (16:49 +0000)
committervh249@arcadians.cl.cam.ac.uk <vh249@arcadians.cl.cam.ac.uk>
Sun, 21 Aug 2005 16:49:54 +0000 (16:49 +0000)
add an error message when having not enough memory

Signed-off-by: Vincent Hanquez <vincent@xensource.com>
tools/python/xen/xm/create.py

index 3770609df69b7b9a47de671c5fec514001f88dcf..ec4ab49c123cdc33576bafb37ed39f580ff9e82f 100644 (file)
@@ -688,7 +688,9 @@ def balloon_out(dom0_min_mem, opts):
     dom0_cur_alloc = get_dom0_alloc()
     dom0_new_alloc = dom0_cur_alloc - (domU_need_mem - free_mem)
 
-    if free_mem < domU_need_mem and dom0_new_alloc >= dom0_min_mem:
+    if free_mem < domU_need_mem and dom0_new_alloc < dom0_min_mem:
+        ret = 1
+    if free_mem < domU_need_mem and ret == 0:
 
         server.xend_domain_mem_target_set(0, dom0_new_alloc)
 
@@ -734,7 +736,8 @@ def main(argv):
         dom0_min_mem = xroot.get_dom0_min_mem()
         if dom0_min_mem != 0:
             if balloon_out(dom0_min_mem, opts):
-                return
+                print >>sys.stderr, "error: cannot allocate enough memory for domain"
+                sys.exit(1)
 
         dom = make_domain(opts, config)
         if opts.vals.console_autoconnect: